package com.wiloon.androidx.broadcast;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.wiloon.androidx.R;

import org.apache.log4j.Logger;

/**
 * Created by wangyue on 9/4/2014.
 */
public class BroadcastReceiverActivity extends Activity {
    private static final Logger logger = Logger.getLogger(BroadcastReceiverActivity.class);

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.broadcast_receiver_activity);
        Button btn = (Button) findViewById(R.id.btnBroadcast);
        btn.setOnClickListener(new myOnClickListener());
    }

    class myOnClickListener implements View.OnClickListener {
        private String BROADCAST = "com.myBroadCast.action";

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(BROADCAST);
            BroadcastReceiverActivity.this.sendBroadcast(intent);
            logger.debug("broadcast sent.");
        }

    }
}